﻿using System;
using System.Data;
using Ue.Framework.Data;
using Ue.Infrastructure.EntityFactoryFramework;
using Ue.Qcdz.Domain.TheSiteConfig;

namespace Ue.Qcdz.Repositories.TheSiteConfig
{
    internal class SiteConfigFactory : IEntityFactory<SiteConfig>
    {
        internal class FieldNames : FieldNamesBase
        {
            public const string Copyright = "Copyright";
            public const string Contact = "Contact";
            public const string Email = "Email";
            public const string Complaint = "Complaint";
            public const string Record = "Record";
            public const string CopyrightEn = "CopyrightEn";
            public const string SiteName = "SiteName";
            public const string MetaKeyworld = "MetaKeyword";
            public const string MetaDescription = "MetaDescription";
        }
        #region Implementation of IEntityFactory<SiteConfig>

        public SiteConfig BuildEntity(IDataReader reader)
        {
            return new SiteConfigProxy(
                reader.Get<string>(FieldNames.SiteName),
                reader.Get<string>(FieldNames.MetaKeyworld),
                reader.Get<string>(FieldNames.MetaDescription),
                reader.Get<string>(FieldNames.Copyright),
                reader.Get<string>(FieldNames.Contact),
                reader.Get<string>(FieldNames.Email),
                reader.Get<string>(FieldNames.Complaint),
                reader.Get<string>(FieldNames.Record),
                reader.Get<string>(FieldNames.CopyrightEn),
                reader.Get<Guid>(FieldNames.EntityKey)
                );
        }

        #endregion
    }
}
